/*-----------------------------------------------------------------------------------
Name: Sangyoon Park
Date: January 23 2023
This do file does : 
	Master do-file to run set of do-files
-----------------------------------------------------------------------------------*/
clear all
set matsize 10000
set maxvar 10000
set more off

#delim ;


/*-----------------------------------------------------------------------------------
			/* Set up */
-----------------------------------------------------------------------------------*/
*** Setting up working directories;

	gl user "sangyoon"; // type in username
	if "${user}"=="sangyoon" gl cdir = "/Users/sangyoon_park/Dropbox/QualityUpgrading"; // type in the home directory you use
	if "${user}"=="sangyoonlaptop" gl cdir = "/Users/Sangyoon Park/Dropbox/QualityUpgrading";
	if "${user}"=="sangyoondesktop" gl cdir = "/Users/Sangyoon/Dropbox/QualityUpgrading";
	if "${user}"=="sangyoonlenovo" gl cdir = "/Users/sangy/Dropbox/QualityUpgrading";	

				
	gl raw_path = "$cdir/Data/rawfile/final";		// path for excel file
	capture mkdir "${raw_path}";
	gl data_path = "$cdir/Data/statafile/final";		// path for stata data file
	capture mkdir "${data_path}";
	gl do_path = "$cdir/Data/dofile/final";			// path for do file
	capture mkdir "${do_path}";
	gl out_path = "$cdir/Data/outputfile/final"; 		// path for stata output file
	capture mkdir "${out_path}";
	capture mkdir "$cdir/Writing"; 	
	gl table_path = "$cdir/Writing/final/tables"; 		// path for tables
	capture mkdir "${table_path}";
	gl figure_path = "$cdir/Writing/final/figures"; 		// path for figures
	capture mkdir "${figure_path}";
		
	
	
/*-----------------------------------------------------------------------------------
			/* Prepare dataset and conduct analysis */
-----------------------------------------------------------------------------------*/

	do "${do_path}/QU_FARMER_COMBINESURVEY_final.do"; // Import and label farmer survey data
	
	do "${do_path}/QU_FARMER_COMBINETRADE_final.do"; // Import and label farmer trade data
	
	do "${do_path}/QU_INTERMEDIARY_COMBINESURVEY_final.do"; // Import and label intermediary survey data
	
	do "${do_path}/QU_INTERMEDIARY_COMBINETRADE_final.do"; // Import and label intermediary trade data
	
	do "${do_path}/QU_PESTICIDE_final.do"; // Import and label pesticide test data

	do "${do_path}/QU_INTERMEDIARYSETUP_final.do"; // Setup intermediary data for analysis
	
	do "${do_path}/QU_FARMERSETUP_final.do"; // Setup farmer data for analysis	

	do "${do_path}/QU_SUMMARY_final.do"; // Summary statistics and balance check
	
	do "${do_path}/QU_TABLES_final.do"; // Create tables in main text	
	
	do "${do_path}/QU_ONLINEAPPENDIX_TABLES_final.do"; // Create tables in online appendix A	

	do "${do_path}/QU_FIGURES_final.do"; // Create figures in main text

	do "${do_path}/QU_ONLINEAPPENDIX_FIGURES_final.do"; // Create figures in online appendix A	
	
	do "${do_path}/QU_SPILLOVER_final.do"; // Create table in online appendix F-1
	
	do "${do_path}/QU_FARMERSETUP_DISPLACEMENT_final.do"; // Setup for online appendix F
	
	do "${do_path}/QU_DISPLACEMENT_final.do"; // Create tables in online appendix F
	

/*-----------------------------------------------------------------------------------
/* For reporting p-values from randomization inference test and multiple hypothesis testing */
-----------------------------------------------------------------------------------*/	
/*	
	* do "${do_path}/QU_RITEST_final.do"; // Report p-values from randomization inference test
	
	* do "${do_path}/QU_MHTESTING_final.do"; // Report false discovery controlled p-values for multiple hypothesis testing
*/	
	

	
	
	
	
	
